package fcrpt

class WipDetailController {
    def dynamicQueryService
    def wipDetail() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def wipDetailSum=[]
        def tableHeadList=[]
        def wipDetail=[]
        def list=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def wipDetailSumQty=[]
        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'wipDetail'
            wipDetail = dynamicQueryService.queryForList(params)
            //list=TranposUtils.colToRow('STEP_NAME','STEP_QTY',partFinList)
            params.SYS_QUERY_NAME = 'wipDetailSumQty'
            wipDetailSumQty = dynamicQueryService.queryForList(params)
            if (wipDetail.size() > 0) {
                tableHeadList = wipDetail[0].keySet()
                params.SYS_QUERY_NAME = 'wipDetailCount'
                totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT

            }else{
                totalCount =0
            }


//            params.SYS_QUERY_NAME = 'orderStatusAnalysisCount'
//            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
//            params.SYS_QUERY_NAME = 'orderStatusAnalysisSum'
//            orderStatusAnalysisSum = dynamicQueryService.queryForList(params)

        }
        print(params.group3)

        [pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent,
         wipDetailSum:wipDetailSum,tableHeadList:tableHeadList,wipDetail:wipDetail,list:list,text:params.text,
         startTime:params.startTime,endTime:params.endTime,partName:params.partName,state:params.state,partDesc:params.partDesc,
         time:params.time,endTime:params.endTime,stepName:params.stepName,stepDesc:params.stepDesc,
         totalGroup:params.totalGroup,detailCate:params.detailCate,partDirection:params.partDirection,group3:params.group3,
         startno:params.startno,endno:params.endno,wipDetailSumQty:wipDetailSumQty]
    }

    def wipDetailStep(){
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10,20,50,100]
        params.SYS_QUERY_NAME = 'wipDetailStep'
        def wipDetailStep = dynamicQueryService.queryForList(params)
        def tableHeadList=[]
        if (wipDetailStep.size() > 0) {
            tableHeadList = wipDetailStep[0].keySet()

        }
        params.SYS_QUERY_NAME = 'wipDetailStepCount'
        def totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        params.SYS_QUERY_NAME = 'wipDetailStepSumQty'
        def wipDetailStepSumQty = dynamicQueryService.queryForList(params)
        [pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent
         ,tableHeadList:tableHeadList,wipDetailStep: wipDetailStep,
         partName1:params.partName1?:'',stepName1:params.stepName1?:'',state1:params.state1?:'',
         lotId:params.lotId?:'',receiveBy:params.receiveBy?:'',receiveName:params.receiveName?:'',
         startno:params.startno?:'',endno:params.endno?:'',wipDetailStepSumQty:wipDetailStepSumQty]
    }
}
